package es.ojugames.yincana.creacion;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import com.google.android.maps.Projection;

import es.ojugames.yincana.R;



public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {

	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private Context context;
	
	public MyItemizedOverlay(Context context, Drawable defaultMarker) {
		super(boundCenterBottom(defaultMarker));
		this.context = context;
	}
	
	@Override
	protected OverlayItem createItem(int i) {
		return mOverlays.get(i);
	}

	@Override
	public int size() {
		return mOverlays.size();
	}
	
	public void clear() {
		mOverlays.clear();
		populate();
	}
	
	public void addPoint(double lat, double lon, String etiqueta){
		int lt = (int) (lat * 1E6);
		int ln = (int) (lon * 1E6);
		
		GeoPoint punto = new GeoPoint(lt, ln);
		OverlayItem item = new OverlayItem(punto, "punto", null);
		mOverlays.add(item);
		populate();
	}
	
	public void addPoint(GeoPoint gp, String etiqueta){
		OverlayItem item = new OverlayItem(gp, "punto", null);
		mOverlays.add(item);
		populate();
	}
}
